package demo.impl;

import demo.AbstractDiscount;

import java.math.BigDecimal;

/**
 * n元购优惠券折扣（ 具体策略 ）
 * @author ZhouWeiBo
 * @create 2022/6/7
 */
public class FewMoney2Buy extends AbstractDiscount {

    private BigDecimal finalMoney = null;


    /**
     * 构建优惠策略
     * @param finalMoney 最后金额
     */
    public FewMoney2Buy(BigDecimal finalMoney) {
        this.finalMoney = finalMoney;
    }

    @Override
    public int order() {
        return Integer.MAX_VALUE;
    }

    @Override
    public BigDecimal discountAmount(BigDecimal bigDecimal) {
        return finalMoney == null ? bigDecimal : finalMoney;
    }
}
